<template>
  <div>
    <el-table :data="comments" :show-header="false">
      <el-table-column>
        <template slot-scope="scope">
          <div class="comment-list">
            <div>
              <el-tag type="info" size="small">会员</el-tag>
              <span class="name">&nbsp;&nbsp;{{ scope.row.username }}</span>
              评论了你的文章 【{{ scope.row.articleTitle }}】
            </div>
            <div>
              {{ scope.row.createTime }}
            </div>
          </div>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <el-pagination
      background
      layout="prev, pager, next"
      :total="this.count"
      :page-size="pageSize"
      :current-page="page"
      @current-change="changePage"
    >
    </el-pagination>
  </div>
</template>
<script>
import { getAdminComments } from "@/api/comment";
export default {
  data() {
    return {
      comments: [],
      page: 1,
      pageSize: 0,
      count: 0,
    };
  },
  created() {
    this.getData();
  },
  methods: {
    async getData() {
      const { data } = await getAdminComments({
        author: this.$store.state.user.username,
        page: this.page,
      });
      this.pageSize = data.pageSize;
      this.count = data.count;
      this.comments = data.result;
    },

    // 分页
    changePage(page) {
      this.page = page;
      this.getData();
    },
  },
};
</script>

<style lang="less" scoped>
.comment-list {
  display: flex;
  justify-content: space-between;
  align-items: center;
 .name{
    color: rgb(52, 25, 172);
    font-weight: 600;
   
  }
}
</style>